﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Composite.Presentation.Commands;

namespace MyApp.Infrastructure.Commanding
{
    public class ActionCommand : DelegateCommand<object>
    {
        public ActionCommand(Action action)
            : this(action, () => true)
        {
        }

        public ActionCommand(Action action, Func<bool> func)
            : base(CreateAction(action), CreateFunc(func))
        {
        }

        private static Action<object> CreateAction(Action action)
        {
            return o => action();
        }

        private static Func<object, bool> CreateFunc(Func<bool> func)
        {
            return o => func();
        }
    }
}
